<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>MyBatis Generator Generated Java Client Objects</title>
  <link rel="stylesheet" type="text/css" href="../mbgstyle.css" />
</head>
<body>
<h1>MyBatis Generator Generated Java Client Objects</h1>
<p>MyBatis Generator (MBG) generates Java client objects of several types.  Java client objects
are used to make interaction with the generated XML elements much easier.
For each table in the configuration, MBG generates one or more Java client objects.  For MyBatis 3,
these are mapper interfaces.  For iBATIS 2.x, these are DAO interfaces and implementation classes.
Generating Java client objects is optional, and is controlled by the
<code>&lt;javaClientGenerator&gt;</code> configuration element.  MBGr can generate clients of the following
types:
</p>
<ul>
  <li>For MyBatis 3.x:
    <ul>
      <li>XMLMAPPER - for use with the MyBatis 3.x mapper support</li>
    </ul>
  </li>
  <li>For iBATIS 2.x:
    <ul>
      <li>IBATIS - for use with the iBATIS DAO Framework</li>
      <li>SPRING - for use with the Spring Framework</li>
      <li>GENERIC-CI - with no dependencies beyond the iBATIS Data Mapper</li>
      <li>GENERIC-SI - also with no dependencies beyond the iBATIS Data Mapper</li>
    </ul>
  </li>
</ul>

<p>Every field and method generated includes the non-standard JavaDoc tag
<code>@mbggenerated</code>.  When run from the Eclipse plugin,
on subsequent runs every field and method that
includes this JavaDoc tag will be deleted and replaced.  Any other field or method in the
class will be untouched.
With this in mind, you can add other fields and methods to the classes without fear of losing them in
subsequent runs - simply DO NOT include the <code>@mbggenerated</code>
JavaDoc tag on anything that you add to the class.</p>

<p>Outside of the Eclipse plugin, Java files need to be merged by hand, but you can use the
<code>@mbggenerated</code> JavaDoc tag to know what is safe to delete from a prior
version of a file.</p>

<p>Note: in the following descriptions, the term "BLOB" is used to refer to any column
with a data type of BLOB, CLOB, LONGVARCHAR, or LONGVARBINARY.</p>

<h2>Methods Common to All DAO Types</h2>
<p>Depending on the specifics of the table, and the configuration options, the Java client generator
will generate these methods:</p>
<ul>
  <li>countByExample</li>
  <li>deleteByPrimaryKey</li>
  <li>deleteByExample</li>
  <li>insert</li>
  <li>insertSelective</li>
  <li>selectByPrimaryKey</li>
  <li>selectByExample</li>
  <li>selectByExampleWithBLOBs</li>
  <li>updateByPrimaryKey (with an override to specify whether or not to update BLOB columns)</li>
  <li>updateByPrimaryKeySelective (will only update non-null fields in the parameter class)</li>
  <li>updateByExample (with an override to specify whether or not to update BLOB columns)</li>
  <li>updateByExampleSelective (will only update non-null fields in the parameter class)</li>
</ul>
<p>MBG attempts to make it easier to deal with tables that contain BLOBs by generating
different objects and methods so that you can use the BLOB fields, or ignore them, depending
on the situation.</p>
<p>See the
<a href="exampleClassUsage.html">Example Class Usage</a>
page for an example of using the <code>selectByExample</code> method.</p>

<h2>XMLMAPPER Clients (MyBatis 3.x)</h2>
<p>XMLMAPPER clients are interfaces that will map to
methods in the generated XML mapper files.  For example, suppos that MBG generated
an interface called <code>MyTableMapper</code>.  You can use the interface as follows:</p>
<pre>
  SqlSession sqlSession = sqlSessionFactory.openSession();

  try {
    MyTableMapper mapper = sqlSession.getMapper(MyTableMapper.class);
    List&lt;MyTable&gt; allRecords = mapper.selectByExample(null);
  } finally {
    sqlSession.close();
  }
</pre>
<p>See the standard MyBatis documentation for details on how to create the instance
of <code>sqlSessionFactory</code>.</p>

<h2>IBATIS DAOs (iBATIS 2.x)</h2>
<p>iBATIS DAOs depend on the iBATIS DAO framework (an optional part of iBATIS - now deprecated).
They extend the SqlMapDaoTemplate class and are
constructed with an instance of the DAOManager object, and call methods in their super class
to execute the different statements.</p>
<p>MBG does not update the "dao.xml" file for you - you must add the appropriate entries
manually.</p>
<p>The iBATIS DAO framework is a very elementary IoC container and can be useful if you
are not already using something like Spring or PicoContainer to manage dependencies.
However, the framework is now deprecated and we suggest that you move to Spring.</p>

<h2>SPRING DAOs (iBATIS 2.x)</h2>
<p>SPRING DAOs depend on the Spring framework.  They extend Spring's SqlMapClientDaoSupport class,
and are constructed by the Spring container.</p>

<h2>GENERIC-CI DAOs (iBATIS 2.x)</h2>
<p>GENERIC-CI DAOs call methods in iBATIS' SqlMapClient interface directly.  An instance of the
interface is supplied through constructor injection.</p>

<h2>GENERIC-SI DAOs (iBATIS 2.x)</h2>
<p>GENERIC-SI DAOs call methods in iBATIS' SqlMapClient interface directly.  An instance of the
interface is supplied through setter injection.</p>

</body>
</html>
